<%= header %>
<%= boomerangScript %>
<script src="07-page-ready-held.js" type="text/javascript"></script>
<script src="../../vendor/resourcetiming-compression/src/resourcetiming-decompression.js" type="text/javascript"></script>

<script>
// Hold the beacon until the following:
// 1. at onload, we'll fire an XHR
// 2. when the XHR is complete, we'll switch to ready
(function() {
	var BOOMR = window.BOOMR || {};
	BOOMR.plugins = BOOMR.plugins || {};

	var ready = false;

	BOOMR.plugins.HoldBeacon = {
		is_complete: function() {
			return ready;
		}
	};

	function onLoad() {
		// trigger 0.5s after onload
		setTimeout(function() {
			// send an xhr
			var xhr = new XMLHttpRequest();
			xhr.open("GET", "/assets/img.jpg");
			xhr.onreadystatechange = function() {
				if (xhr.readyState !== 4) {
					return;
				}

				ready = true;

				// add restiming to the beacon
				BOOMR.plugins.ResourceTiming.addResourceTimingToBeacon();

				// send the beacon
				BOOMR.sendBeacon();
			};
			xhr.send(null);
		}, 500);
	}

	if (window.addEventListener) {
		window.addEventListener("load", onLoad, false);
	}
	else if (window.attachEvent) {
		window.attachEvent("onLoad", onLoad);
	}
})();

BOOMR_test.init({
	testAfterOnBeacon: true,
	ResourceTiming: {
		enabled: true
	}
});
</script>
<%= footer %>
